appendFile
Files Sandbox MaheP Mar21 Revised

Appending a Local File

Problem
=======

Given the name of a file and it's path, how to append to that file.

Solution
========

Referring to the previous example of creating a file in which the operator ">"
was used to create a file and add lines to it. The gotcha with the ">" operator
is that during the execution of the awk program, the first time the ">" operator
is invoked on a particular file, a new file is created. This means that even if
the file exists, the file is truncated to size 0 before anything is writeen to
it.

Now, in case if we do not need to create a new file, but rather append to an
existing file, the ">" has to be changed to ">>".

  print "Hello World!" >> "MyFile.txt"

The function to append to a file becomes:

 function appendFile(string, path, filename)
 {
     print string >> path"/"filename;
 }



Author
======

Mahesh Patel


